<?php
/**
 * 
 * 用户管理模块
 * @author ChunYang.Jiang<chunyang@staff.sina.com.cn>
 * @copyright sina
 * @version $Id$
 *
 */
class UserModule extends ModuleBase
{
	public static function add($row)
	{
		return parent::queryInsert($row, 'admin_user'); 
	}
	
	public static function getUserById($uid)
	{
		$where = array('uid'=>$uid); 
		return parent::querySelectSingle(array('*'), $where, 'admin_user');
	}
	
	public static function del($uid)
	{
		$where = array('uid'=>$uid);
		return parent::queryDelete($where, 'admin_user');
	}
	
	public static function getUserByUname($uname)
	{
		$where = array('uname'=>$uname);
		return parent::querySelectSingle(array('*'), $where, 'admin_user');
	}
	
	public static function update($uid, $row)
	{
		$where = array('uid'=>$uid);
		return parent::queryUpdate($row, $where, 'admin_user');
	}
	
	public static function getUser($where=1, $order='id asc', $start=0, $limit=20, &$total=0)
	{
		$total = 0;
		$result = parent::querySelectSingle(array("count(0) as num"), $where, 'admin_user');
		if ($result && isset($result['num'])){
			$total = $result['num'];
		}else{
			return false;
		}
		return parent::querySelect(array('*'), $where, 'admin_user', 'uid asc', $start, $limit); 
	}
}